package entity;

import com.github.javaparser.ast.type.TypeParameter;
import com.thoughtworks.qdox.model.JavaClass;

import java.util.List;

public class MethodEntity extends CallableEntity {

    private String name;
    private boolean isFinal;    // 是否允许重写
    private boolean isStatic;   // 是否是静态方法
    private boolean isAbstract; // 是否是抽象方法
    private boolean isSynchronized; // 是否有同步锁
    private boolean isStrictfp; // 精确浮点
    private boolean isNative;   // 调用原生库（其他语言）

    private List<TypeParameter> typeParameters;  // 类型变量声明
    private JavaClass returns; //方法返回值

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isFinal() {
        return isFinal;
    }

    public void setFinal(boolean aFinal) {
        isFinal = aFinal;
    }

    public boolean isStatic() {
        return isStatic;
    }

    public void setStatic(boolean aStatic) {
        isStatic = aStatic;
    }

    public boolean isAbstract() {
        return isAbstract;
    }

    public void setAbstract(boolean anAbstract) {
        isAbstract = anAbstract;
    }

    public boolean isSynchronized() {
        return isSynchronized;
    }

    public void setSynchronized(boolean aSynchronized) {
        isSynchronized = aSynchronized;
    }

    public boolean isStrictfp() {
        return isStrictfp;
    }

    public void setStrictfp(boolean aStrictfp) {
        isStrictfp = aStrictfp;
    }

    public boolean isNative() {
        return isNative;
    }

    public void setNative(boolean aNative) {
        isNative = aNative;
    }

    public List<TypeParameter> getTypeParameters() {
        return typeParameters;
    }

    public void setTypeParameters(List<TypeParameter> typeParameters) {
        this.typeParameters = typeParameters;
    }

    public JavaClass getReturns() {
        return returns;
    }

    public void setReturns(JavaClass returns) {
        this.returns = returns;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("MethodEntity{\n\t");
        sb.append(super.toString());
        sb.append("\n\t\"name\":\"")
                .append(name).append('\"');
        sb.append(",\n\t\"isFinal\":")
                .append(isFinal);
        sb.append(",\n\t\"isStatic\":")
                .append(isStatic);
        sb.append(",\n\t\"isAbstract\":")
                .append(isAbstract);
        sb.append(",\n\t\"isSynchronized\":")
                .append(isSynchronized);
        sb.append(",\n\t\"isStrictfp\":")
                .append(isStrictfp);
        sb.append(",\n\t\"isNative\":")
                .append(isNative);
        sb.append(",\n\t\"typeParameters\":")
                .append(typeParameters);
        sb.append(",\n\t\"returns\":")
                .append(returns);
        sb.append("\n}");
        return sb.toString();
    }
}
